<?php
session_start();
?>
<?php require_once('Conection_DataBase.php') ?>
<?php
//mysql_select_db($database_jssue);
$usu = $_SESSION["UsuSelect"];
$Querry_recordSet = "select cllg_menu.TITTLE,cllg_menu.ID,cllg_acces.status,cllg_acces.FK_MENU 
    from cllg_acces,cllg_menu,cllg_perfil where cllg_acces.FK_PERFIL = '$usu'
 and cllg_acces.FK_MENU = cllg_menu.ID and cllg_menu.ORDEN = 0 group by cllg_menu.id";
$recordset = mysql_query($Querry_recordSet, $jssue) or die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Clientes individuales</title>
        <link href="../../css/ContentStyle.css" rel="stylesheet" type="text/css" />
        <link href="../../bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
        <script src="../../js/jquery.js" type="text/javascript"></script>
        <script>jQuery.noConflict();</script>
        <script src="../../bootstrap/js/bootstrap.js"></script>
    </head>

    <body>
        <table width="600" height="101" border="0" cellpadding="2" cellspacing="0" class="">
            <thead>

                <tr >
                    <th width="434" height="3" align="left" valign="bottom"><legend>Titulo Menu</legend>
                        <th width="123" align="center"><strong><legend>Operaciones</legend></strong></tr>
                            </thead>
                            <?php
                            while ($prueba = mysql_fetch_assoc($recordset)) {
                                $id = $prueba["ID"];
                                $stado1 = $prueba["status"];
                                $idCllAcces = $prueba["FK_MENU"];
                                ?>
                                <tr>
                                    <td height="20"><br/><strong><legend><?PHP echo $prueba["TITTLE"]; ?></legend></strong>
                                        <td align="center" valign="middle"><?php if ($stado1 == 1) {
                                $idCllAcces = $idCllAcces . "-0";
                                    ?><input type="image" src="./images/icon_delete.gif" title="DESACTIVAR" alt="DESACTIVAR" name="button22" id="button22" onclick="javascript:ingreHijo('<?php echo $idCllAcces; ?>')"/>
                                            <?php } ?><?php if ($stado1 == 0) {
                                            $idCllAcces = $idCllAcces . "-1";
                                                ?><input type="image" src="./images/add1.png" title="INGRESAR" alt="INGRESAR" name="button22" id="button22" onclick="javascript:ingreHijo('<?php echo $idCllAcces; ?>')"/>
    <?php } ?></td>
    <?php $idde = $id . "_" . "1" ?>
                                </tr>

                                <tr>
                                    <td height="27" colspan="2"><?PHP if (!$id == "") { ?><table width="561" border="0" cellspacing="0">
                                                <?PHP
                                                $Querry_recordSetM = "select cllg_menu.URL,cllg_menu.TITTLE,cllg_menu.ID,cllg_menu.MENU_PARENT,cllg_acces.status,cllg_acces.FK_MENU from cllg_acces,cllg_menu,cllg_perfil where cllg_acces.FK_PERFIL = '$usu' and cllg_acces.FK_MENU = cllg_menu.ID and cllg_menu.ORDEN = '$id' and cllg_menu.MENU_PARENT <= 2 group by cllg_menu.id";
                                                $recordsetM = mysql_query($Querry_recordSetM, $jssue) or die(mysql_error());
                                                ?>
                                                <?php
                                                while ($pruebaM = mysql_fetch_assoc($recordsetM)) {
                                                    $idHijo = $pruebaM["ID"];
                                                    if ($pruebaM["MENU_PARENT"] >= 2) {
                                                        $Subsuba = "SI";
                                                    } else {
                                                        $Subsuba = "NO";
                                                    }
                                                    $stado2 = $pruebaM["status"];
                                                    $idCllAcces2 = $pruebaM["FK_MENU"];
                                                    ?>
                                                    <tr>
                                                        <td width="37" rowspan="2">&nbsp;</td>
                                                        <td width="156"><?PHP echo $pruebaM["TITTLE"]; ?></td>
                                                        <td width="183"><?PHP echo $pruebaM["URL"]; ?></td>
                                                            <?php $iddeHijo = $idHijo ?>
                                                        <td width="109"><?php if ($stado2 == 1) {
                                                    $idCllAcces2 = $idCllAcces2 . "-0";
                                                                ?><input type="image" src="./images/icon_delete.gif" title="DESACTIVAR" alt="DESACTIVAR" name="button22" id="button22" onclick="javascript:ingreHijo('<?php echo $idCllAcces2; ?>')"/>
                                                            <?php } ?><?php if ($stado2 == 0) {
                                                    $idCllAcces2 = $idCllAcces2 . "-1";
                                                    ?>
                                                                <input type="image" src="./images/add1.png" title="INGRESAR" alt="INGRESAR" name="button22" id="button22" onclick="javascript:ingreHijo('<?php echo $idCllAcces2; ?>')"/>
                                                                <?php } ?></td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="3"><?PHP if ($Subsuba == "SI") { ?><table width="515" border="0" cellspacing="0">
                                                                    <?PHP
                                                                    $idmenu = $pruebaM["ID"];
                                                                    $Querry_recordSetSUb = "select * from cllg_menu where ORDEN = '$idmenu'";
                                                                    $recordsetSUb = mysql_query($Querry_recordSetSUb, $jssue) or die(mysql_error());
                                                                    ?>
                                                                    <?PHP while ($pruebaSUb = mysql_fetch_assoc($recordsetSUb)) { ?>
                                                                        <?PHP $idSUB = $pruebaSUb["ID"]; ?>
                                                                        <?php
                                                                        $Querry_recordSetREcu = "select * from cllg_acces where FK_MENU = '$idSUB' and FK_PERFIL = '$usu'";
                                                                        $recordsetREcu = mysql_query($Querry_recordSetREcu, $jssue) or die(mysql_error());
                                                                        $pruebaREcu = mysql_fetch_assoc($recordsetREcu);
                                                                        ?>
                    <?php //$idSUB = $idSUB."_"."3" ?>
                    <?php $stado3 = $pruebaREcu["status"]; ?>
                                                                        <tr>
                                                                            <td width="52">&nbsp;</td>
                                                                            <td width="138"><?PHP echo $pruebaSUb["TITTLE"]; ?></td>
                                                                            <td width="158"><?PHP echo $pruebaSUb["URL"]; ?></td>
                                                                            <td width="108"><?php if ($stado3 == 1) {
                                                                $idSUB = $idSUB . "-0";
                                                                ?><input type="image" src="./images/icon_delete.gif" title="DESACTIVAR" alt="DESACTIVAR" name="button22" id="button22" onclick="javascript:ingreHijo('<?php echo $idSUB; ?>')"/><?php } ?><?php if ($stado3 == 0) {
                                                                $idSUB = $idSUB . "-1";
                        ?><input type="image" src="./images/add1.png" title="INGRESAR" alt="INGRESAR" name="button22" id="button22" onclick="javascript:ingreHijo('<?php echo $idSUB; ?>')"/>
                                                    <?php } ?></td>
                                                                        </tr><?PHP } ?>
                                                                </table><?PHP } ?></td>
                                                    </tr>
        <?PHP } ?>
                                            </table>
    <?PHP } ?>             </tr>

<?PHP } ?>
                            </table>
                            </body>
                            </html>
